package com.geektime.hello.controller;

import com.geektime.hello.common.Result;
import com.geektime.hello.entity.Student;
import com.geektime.hello.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: DRevelation
 * @Date: 2021/1/4 9:57
 */
@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired
    private StudentMapper studentMapper;

    @GetMapping("save")
    public Result save() {
        Student student = Student.builder().deptId(1).name("haha").remark("haha").build();
        studentMapper.insert(student);
        return Result.success();
    }

    @GetMapping("getAll")
    public Result getAll() {
        List<Student> studentList = studentMapper.selectList(null);
        return Result.success(studentList);
    }
}
